<template>
  <div>
    <div class="lhxwjl-bt">个人获奖表</div>
    <CustomTable
      ref="table"
      :showAlert="false"
      :showSelection="false"
      :columns="grhjColumns"
      :loading="load"
      @change="onTableChange"
      :dataSource="pageData"
      :pageSizeOptions="['5','10']"
      style="margin-top:20px;"
    >
     <template slot="xh" slot-scope="text, record, index">
        {{((pageFilter.pageNo - 1) * pageFilter.pageSize +(index + 1))>9?(pageFilter.pageNo - 1) * pageFilter.pageSize +(index + 1) :'0' + (index + 1) }}
      </template>
      <template slot="timeBj" slot-scope="record">
        <span v-if="record!=='' && record!==null">{{ moment(record).format("YYYY-MM-DD") }}</span>
      </template>
    </CustomTable>
  </div>
</template>

<script>
import emv from "@/views/center/emptyVue.vue";
import api from '@/api/index'
export default {
  props: {
    codeZzjg: {
      type: String
    }
  },
  data() {
    return {
      load: false,
      grhjColumns: [
        {
          title: "序号",
          dataIndex: "xh",
          key: "xh",
          width:80,
          scopedSlots: { customRender: "xh" }
        },
        {
          title: "姓名",
          dataIndex: "name",
          key: "name",
          ellipsis: true,
        },
        {
          title: "奖项名称",
          dataIndex: "nameAwards",
          key: "nameAwards",
          ellipsis: true,
        },
        {
          title: "颁奖单位",
          dataIndex: "unitAwards",
          key: "unitAwards",
          ellipsis: true,
        },
        {
          title: "颁奖时间",
          dataIndex: "timeAwards",
          key: "timeAwards",
          ellipsis: true,
          scopedSlots: { customRender: "timeAwards" }
        },
        {
          title: "颁奖文号",
          dataIndex: "hjwh",
          key: "hjwh",
          ellipsis: true,
        }
      ],
      pageData: [],
      pageFilter: {
        pageNo: 1,
        pageSize: 10,
        isPass:true,
      },
    };
  },
  created() {
    this.pageFilter.codeZzjg = this.codeZzjg;
    this.refreshTable();
  },
  methods: {
    onTableChange(pageFilter) {
      this.pageFilter = { ...this.pageFilter, ...pageFilter };
      this.refreshTable();
    },
    async refreshTable() {
        this.load = true;
        await api.get_ryxx_lhjl_list(this.pageFilter) .then(res => {
          let pageNo = this.pageFilter.pageNo;
          let pageSize = this.pageFilter.pageSize;
          let records = res.rows;
          let total = res.total;
          this.pageData = {
            ...this.pageData,
            pageNo,
            records,
            pageSize,
            total
          };
          this.load = false;
            
        })
        .catch(err => {
          this.load = false;
        });

      },
  }
};
</script>

<style lang="less">
.lhxwjl-bt {
  color: #333333;
  font-size: 16px;
  font-weight: 400;
  margin-top: 20px;
  margin-left: 10px;
}
</style>